void a(vector<TH1F *> &v, TObject *h){ v.push_back((TH1F *)h); }
void rrdcx(){
  TFile *f = new TFile(getenv("TMP1"), "UPDATE");
  TTree *etf = (TTree *)f->Get("etf");
  vector<TH1F *> v;
  TH1 *h0;
  char zcut[64] = "";
  static const int Z = 29;
  if(Z > 0) sprintf(zcut, "az0>%.2f && az0<%.2f", Z-0.5, Z+0.5);

  // --------------------- 2. Wire Id Distribution ------------------------ //
  const char xuv[3] = {'X', 'U', 'V'};
  char hname[64]{}, ly[64]{};
  int id = 0;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 1; j++){
      sprintf(ly, "dc%d%c", i, xuv[j]);
      sprintf(hname, "h%s", ly);
      h0 = new TH2F(hname, Form("r1-r2 of %s", ly), 500, -1., 6., 0, -1., 6.);
      h0->GetXaxis()->SetTitle("drift distance of X0 [mm]");
      h0->GetYaxis()->SetTitle("drift distance of X1 [mm]");
      string cut = Form("%s&&fabs(postMagTrackerX.ang()-15.)<1.&&%s0.fired()>=2&&%s1.fired()>=2", zcut, ly, ly);
      etf->Project(hname, Form("%s1.GetR():%s0.GetR()", ly, ly), cut.data());
      a(v, h0);
      cout << "Processing " << ly << ": " << zcut << "...\r" << flush;
    } // end for over x,u,v
  } // end for over dcs

  TCanvas *c = new TCanvas("c", "r1-r2 for post Mag dcs", 1680, 1050);
  c->Divide(3, 1);
  for(int i = 0; i < 3; i++){
    c->cd(i+1); v[i]->Draw("colz");
  } // end for
  c->Print("rrdcx.pdf");
} // end vis
